package com.yc.so.demo.font;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import java.util.HashMap;
import java.util.Map;


public class Main1 extends Application {
    private static final Font GLYPH_FONTAWESOME = Font.loadFont(Main1.class.getResourceAsStream("iconfont.ttf"), -1);
    private static final Map<String, Character> GLYPH_MAP;


    static {
        GLYPH_MAP = new HashMap<String, Character>();
        //反馈
        GLYPH_MAP.put("icon-comments", '\ue6f2');
        //设置
        GLYPH_MAP.put("icon-set", '\ue70a');
        //搜索
        GLYPH_MAP.put("icon-search", '\ue70b');
        //刷新
        GLYPH_MAP.put("icon-exchangerate", '\ue712');
        //关闭
        GLYPH_MAP.put("icon-close", '\ue6f0');
    }
    public static void main(String[] args) {
        launch(args);
    }

    public void start(Stage stage) throws Exception {
        AnchorPane pane=new AnchorPane();
        HBox b1=new HBox();
        b1.setPrefHeight(25);
        b1.setPrefWidth(650);
        b1.setStyle("-fx-background-color: #0A0B1A");
        HBox b2=new HBox();
        b2.setPrefHeight(50);
        b2.setPrefWidth(650);
        b2.setLayoutY(25);
        b2.setStyle("-fx-background-color: #fff");

        pane.getChildren().addAll(b2,b1);

        Scene scene=new Scene(pane);
        stage.setScene(scene);
        stage.setHeight(75);
        stage.setWidth(650);
        stage.initStyle(StageStyle.TRANSPARENT);
        stage.show();


        int sizeFactor=3;
        Font f = Font.font(GLYPH_FONTAWESOME.getFamily(), 8 * sizeFactor);
        Stop[] stops = new Stop[]{new Stop(0, Color.WHITE)};
        LinearGradient lg1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);


        Label close=new Label();
        close.setFont(f);
        close.setText(String.valueOf(GLYPH_MAP.get("icon-comments")));
        close.setTextFill(lg1);

        Label comments=new Label();
        comments.setFont(f);
        comments.setText(String.valueOf(GLYPH_MAP.get("icon-comments")));
        comments.setTextFill(lg1);

        Label set=new Label();
        set.setFont(f);
        set.setText(String.valueOf(GLYPH_MAP.get("icon-comments")));
        set.setTextFill(lg1);

        b1.getChildren().addAll(close,comments,set);

        b1.setAlignment(Pos.BASELINE_RIGHT);


        TextField area=new TextField();

        b2.getChildren().addAll(area);

    }
}
